package edu.sctu.zhoumengxue.day201505.day20150522.student;

import java.util.Iterator;
import java.util.LinkedList;

/**
 * Created by user12 on 2015/5/22.
 */
public class Main {

    public static void main(String[] args) {
        //声明LinkedList并实例化
        LinkedList list = new LinkedList();
        //使用add()方法添加元素
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");
        // 使用Iterator迭代器遍历出集合的元素并打印
        for (Iterator i = list.iterator(); i.hasNext(); ) {
            String string = (String) i.next();
            System.out.println(string);

        }
        System.out.println("____");
        //向链表头和谓分别添加X和Z
        list.addFirst("z");
        list.addLast("x");
        //遍历查看添加后的结果
        for (Iterator i = list.iterator(); i.hasNext(); ) {
            String string = (String) i.next();
            System.out.println(string);


        }

        ListAdd listAdd = new ListAdd();
        listAdd.ListAdd();
    }
}
